import os
import pickle
import numpy as np

data_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'data'))
features_path = os.path.join(data_path, 'image_features')

def load_index():
    with open(os.path.join(data_path, 'cache_color_feature.bin'), 'rb') as fp:
        indices = pickle.load(fp)
    return indices

def load_index():
    indices = {}
    with open(os.path.join(data_path, 'cache_color_feature.bin'), 'rb') as fp:
        tmp_datas = pickle.load(fp)
        for data in tmp_datas:
            id = data['id']
            features = data['features']
            path = data['path']
            indices[id] = (features, path)
    return indices

def load_invert_index():
    with open(os.path.join(data_path, 'invert_indices_color.bin'), 'rb') as fp:
        invert_indices = pickle.load(fp)
    return invert_indices